package com.lots.ai.tools;

import com.lots.ai.entity.po.Product;
import com.lots.ai.entity.po.UserInfo;
import com.lots.ai.service.IProductService;
import com.lots.ai.service.IUserInfoService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.stereotype.Component;

import java.util.List;

@RequiredArgsConstructor
@Component
@Slf4j
public class CourseTools {

    private final IUserInfoService userInfoService;
    private final IProductService  productService;




    @Tool(description = "查询所有商品信息")
    public List<Product> queryAllProducts() {
        log.info("查询数据库商品信息");
        return productService.list();
    }

    @Tool(description = "生成商品预购单,并返回生成的预约信息id")
    public String generateCourseReservation(String name, String contactPhone, String notes) {
        //创建对象
        UserInfo userInfo = new UserInfo();
        //设置属性
        userInfo.setName(name);
        userInfo.setContactPhone(contactPhone);
        userInfo.setNotes(notes);
        //保存信息
        userInfoService.save(userInfo);
        return String.valueOf(userInfo.getId());
    }
} 